package com.zhoug.demo.sendpush;

import android.content.SharedPreferences;

import com.zhoug.common.utils.JsonUtils;
import com.zhoug.common.utils.SpUtils;
import com.zhoug.demo.sendpush.huawei.HuaweiPushToken;

/**
 * @description: 类的简要描述
 * @author: 35574
 * @date: 2025/11/4 18:21
 */
public class SharedPre {
    private static final String HUAWEI_PUSH_SERVER_TOKEN = "HUAWEI_PUSH_SERVER_TOKEN";
    private static final String HUAWEI_PUSH_APP_TOKEN = "HUAWEI_PUSH_APP_TOKEN";
    private static final String HUAWEI_PUSH_PROJECTID = "HUAWEI_PUSH_PROJECTID";
    private static final String HUAWEI_PUSH_CLIENTID = "HUAWEI_PUSH_CLIENTID";
    private static final String HUAWEI_PUSH_CLIENTSECRET = "HUAWEI_PUSH_CLIENTSECRET";
    private static final String HUAWEI_PUSH_CONFIG = "HUAWEI_PUSH_CONFIG";

    private static SharedPreferences getSharedPre() {
        return SpUtils.getSharedPreferences("push_tokens");
    }

    public static void keepHuaweiServerToken(String key,HuaweiPushToken token) {
        getSharedPre().edit()
                .putString(key, JsonUtils.toJson(token))
                .apply();
    }

    public static HuaweiPushToken getHuaweiServerToken(String key) {
        String result = getSharedPre().getString(key, null);
        return JsonUtils.fromJson(result, HuaweiPushToken.class);
    }

  /*  public static void keepHuaweiAppToken(String token){
        getSharedPre().edit()
                .putString(HUAWEI_PUSH_APP_TOKEN, token)
                .apply();
    }

    public static String getHuaweiAppToken( ){
        return getSharedPre().getString(HUAWEI_PUSH_APP_TOKEN,null);
    }*/

    //
  /*  public static void keepHuaweiProjectId(String token){
        getSharedPre().edit()
                .putString(HUAWEI_PUSH_PROJECTID, token)
                .apply();
    }

    public static String getHuaweiProjectId( ){
        return getSharedPre().getString(HUAWEI_PUSH_PROJECTID,null);
    }*/

    /*public static void keepHuaweiClientId(String token){
        getSharedPre().edit()
                .putString(HUAWEI_PUSH_CLIENTID, token)
                .apply();
    }

    public static String getHuaweiClientId( ){
        return getSharedPre().getString(HUAWEI_PUSH_CLIENTID,null);
    }*/

    /*public static void keepHuaweiClientSecret(String token){
        getSharedPre().edit()
                .putString(HUAWEI_PUSH_CLIENTSECRET, token)
                .apply();
    }

    public static String getHuaweiClientSecret( ){
        return getSharedPre().getString(HUAWEI_PUSH_CLIENTSECRET,null);
    }*/


    public static void keepHuaweiPushConfig(PushConfig token) {
        getSharedPre().edit()
                .putString(HUAWEI_PUSH_CONFIG, JsonUtils.toJson(token))
                .apply();
    }

    public static PushConfig getHuaweiPushConfig() {
        String result = getSharedPre().getString(HUAWEI_PUSH_CONFIG, null);
        return JsonUtils.fromJson(result, PushConfig.class);
    }

}
